//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "InvoiceReportDlg.h"
#include "FormUtilities.h"
#include "InvoiceReport.h"

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
//---------------------------------------------------------------------------
__fastcall TfrmInvoiceReportDlg::TfrmInvoiceReportDlg(TComponent* Owner, TDatabase * dbMain)
        : TForm( Owner)
{
   Word year;
   Word month;
   Word day;

   TFormUtilities::LocateForm(( TForm*)Owner, this);
   this->dbMain = dbMain;

   FillMonthCombo();
   DecodeDate( Now(), year, month, day);
   edtYear->Text = IntToStr( year);
   cmbMonth->ItemIndex = month - 1; 
}

void TfrmInvoiceReportDlg :: FillMonthCombo()
{
   AnsiString month;
   int        i;

   for ( i = 1; i <= 12; i++)
   {
      DateTimeToString( month, "mmmm", EncodeDate( 2004, i, 1));
      cmbMonth->Items->Add( month);
   }//for
}

void __fastcall TfrmInvoiceReportDlg::btnCloseClick(TObject *Sender)
{
   Close();
}
//---------------------------------------------------------------------------

void __fastcall TfrmInvoiceReportDlg::BitBtn1Click(TObject *Sender)
{
   TfrmInvoiceReport * frmInvoiceReport;

   frmInvoiceReport = new TfrmInvoiceReport( this, dbMain);

   try
   {
      frmInvoiceReport->Preview( StrToInt( edtYear->Text), cmbMonth->ItemIndex + 1);          
   }
   __finally
   {
      delete frmInvoiceReport;
   }//try-finally
}
//---------------------------------------------------------------------------

